﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using MyWCFServices.RealRestaurantService;

namespace ITKRestaurant
{
    /// <summary>
    /// Interaction logic for AsztalGUI.xaml
    /// </summary>
    public partial class AsztalGUI : UserControl
    {
        private Asztal asztal;

        public AsztalGUI(Asztal asztal)
        {
            this.asztal = asztal;
            InitializeComponent();
            this.Margin = new Thickness(this.asztal.AsztalX, this.asztal.AsztalY,0,0);
            this.HorizontalAlignment = HorizontalAlignment.Left; //bucso: Azért, hogy abszolút legyen az elérés
            this.VerticalAlignment = VerticalAlignment.Top; //bucso: Azért, hogy abszolút legyen az elérés

            initAsztal();
            initFlags();
        }

        public void initFlags()
        {
            if (this.asztal.AsztalStatusz == 1)
            {
                this.labelFull.Visibility = Visibility.Visible;
                this.labelReserved.Visibility = Visibility.Hidden;
            }
            else if (this.asztal.AsztalStatusz == 2)
            {
                this.labelFull.Visibility = Visibility.Hidden;
                this.labelReserved.Visibility = Visibility.Visible;
            }
            else if (this.asztal.AsztalStatusz == 3)
            {
                this.labelFull.Visibility = Visibility.Visible;
                this.labelReserved.Visibility = Visibility.Visible;
            }
            else
            {
                this.labelFull.Visibility = Visibility.Hidden;
                this.labelReserved.Visibility = Visibility.Hidden;
            }
        }

        public void initAsztal()
        {
            this.labelSzam.Content = this.asztal.AsztalSzam;
            this.labelFo.Content = "";
            this.labelFo.Content = this.asztal.AsztalFo + " fő";

            if (this.asztal.AsztalMaxFo == 1)
            {
                this.image1.Source = new BitmapImage(new Uri("/Images/11.png", UriKind.RelativeOrAbsolute));
            }
            else if (this.asztal.AsztalMaxFo == 2)
            {
                this.image1.Source = new BitmapImage(new Uri("/Images/2.png", UriKind.RelativeOrAbsolute));
            }
            else if (this.asztal.AsztalMaxFo == 3)
            {
                this.image1.Source = new BitmapImage(new Uri("/Images/3.png", UriKind.RelativeOrAbsolute));
            }
            else
            {
                this.image1.Source = new BitmapImage(new Uri("/Images/4.png", UriKind.RelativeOrAbsolute));
            }
        }

        public Asztal getAsztal() { return this.asztal; }

        private void Grid_MouseEnter(object sender, MouseEventArgs e)
        {
            this.keret.Stroke = Brushes.Red;
            this.Cursor = Cursors.Hand;
        }

        private void Grid_MouseLeave(object sender, MouseEventArgs e)
        {
            this.keret.Stroke = null;
            this.Cursor = Cursors.Arrow;
        }

        public void Set_Changes()
        {
            initAsztal();
            initFlags();
        }
    }
}
